<?php
///////////////////////////////////////////////////////////////////////////////
// File:          tags.php
// Description:   Displays the user's flickr tag cloud.
///////////////////////////////////////////////////////////////////////////////
require_once("inc/header.php");

$tags = $f->tags_getListUserPopular($config_flickrUserId, $config_tagCount);

//
// Find the maximum occurence of the 100 most frequently used tag
//
$tagMax = 0;
foreach ($tags as $tag)
{
   if ($tagMax < $tag[count])
      $tagMax = $tag[count];
}

//
// Build the tag cloud by wrapping the tag name into a span styled: tag_xsmall,
// tag_small, tag_medium, tag_large, tag_xlarge.
//
$tag_xsmall = $tagMax / 5;
$tag_small  = $tag_xsmall * 2;
$tag_medium = $tag_xsmall * 3;
$tag_large  = $tag_xsmall * 4;

$tagData = "";
foreach ($tags as $tag)
{
   $tagData .= "<a href='recent.php?tag=" . $tag['_content'] . "'>";
   
   if (0 < $tag['count'] && $tag['count'] <= $tag_xsmall)
   {
      $tagData .= "<span class='tag_xsmall'>" . $tag['_content'] . "</span> ";
   }
   else if ($tag_xsmall < $tag['count'] && $tag['count'] <= $tag_small)
   {
      $tagData .= "<span class='tag_small'>" . $tag['_content'] . "</span> ";
   }
   if ($tag_small < $tag['count'] && $tag['count'] <= $tag_medium)
   {
      $tagData .= "<span class='tag_medium'>" . $tag['_content'] . "</span> ";
   }
   if ($tag_medium < $tag['count'] && $tag['count'] <= $tag_large)
   {
      $tagData .= "<span class='tag_large'>" . $tag['_content'] . "</span> ";
   }
   if ($tag_large < $tag['count'])
   {
      $tagData .= "<span class='tag_xlarge'>" . $tag['_content'] . "</span> ";
   }
   
   $tagData .= "</a>";
}
?>

<div id='page_header'>
   <span id='page_title'>Tags</span>
   <span id='page_nav'></span>
</div>

<div id='page'>
   <div id='tag_container'>
      <?php echo $tagData; ?>
   </div>
</div>

<?php
require_once("inc/footer.php"); 
?>
